﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace Signage01
{
    class HourMinuteSecondConverter : IValueConverter
    {
        public HourMinuteSecondConverter()
        {

        }

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
           // Console.WriteLine("value is:" + value);
            Int32 initialSecond = System.Convert.ToInt32(value);
            Int32 ss = initialSecond % 60;
            Int32 mm = initialSecond / 60;
            Int32 hh = initialSecond / 3600;
            //Console.WriteLine("hour:" + hh + ",minute: " + mm + ",second:" + ss);
            return string.Format(@"{0:D2}:{1:D2}:{2:D2}", hh, mm, ss);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return Binding.DoNothing; // Thanks to Danny Varod for the suggestion!
        }

    }
}
